Skip to content

Handle nested JSON type mismatches in non-strict matcher - #815

Open
liuyaohui666 wants to merge 1 commit into
getsentry:masterfrom
liuyaohui666:fix/non-strict-json-type-mismatch
Open

Handle nested JSON type mismatches in non-strict matcher#815
liuyaohui666 wants to merge 1 commit into
getsentry:masterfrom
liuyaohui666:fix/non-strict-json-type-mismatch

Conversation

@liuyaohui666

Copy link
Copy Markdown

What type of PR is this? (check all applicable)

  • Bug Fix
  • Feature
  • Documentation Update

Description

In non-strict mode, json_params_matcher currently raises TypeError when the actual value at a matched key is a nested object but the expected value is a scalar. _filter_dict_recursively assumes the expected value is also a dictionary before recursing.

This change only recurses when both sides are dictionaries. The resulting filtered value then goes through the matcher's normal comparison path and produces a useful mismatch reason.

Related Tickets & Documents

Fixes #814

Added/updated tests?

  • Yes
  • No, and this is why: please replace this line with details on why tests have not been included
  • I need help with writing tests

The regression test covers an actual nested object compared with an expected scalar in non-strict mode.

Local verification:

  • pytest responses/tests/test_matchers.py -q — 43 passed
  • The broader suite reached 218 passed; 12 tests could not start because pytest-httpserver was unavailable in the local environment.
  • git diff --check

Updated CHANGES?

  • Yes
  • No, and this is why: please replace this line with details on why CHANGES have not been updated

Are there any post deployment tasks we need to perform?

None.

AI assistance disclosure

OpenAI Codex (GPT-5) assisted with investigation, the reproducer, regression test, implementation, and drafting this PR. I reviewed the diff and ran the checks listed above locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-strict json_params_matcher raises TypeError on nested object/scalar mismatch

1 participant